/**
 * 流程信息表 编辑页
 *
 * 作者 fenghaijun
 * 日期 2024-07-15 17:34:52
 */
layui.use(['jquery', 'febs', 'form', 'laydate', 'commonJS', 'element'], function () {
    var $ = layui.$,
        febs = layui.febs,
        layer = layui.layer,
        form = layui.form,
        commonJS = layui.commonJS,
        $view = $('#workflowInfo-edit'),
        validate = layui.validate,
        branchNode,
        selectMap = new Map();

    form.verify(validate);
    form.render();
    //分支初始化业务表
    getTableNameList()
    //分支 初始化自定义下拉
    getBranch()

    //流程设计
    let workflowData = new Map()
    var workflow = new Workflow({
        menus: [{
            type: 'approve', // 节点类型：node-条件节点
            icon: 'user-o', // 图标，参考 fontasome
            color: 'orange', // 图标颜色定制，默认蓝色
            text: '业务节点',
            node: { // 可预定义配置
                tips: '业务节点',
                icon: 'edit',
                name: '业务节点',
                text: '请配置业务节点', // 也支持function，this指向 properties
                properties: {}
            },
            // 自定义非空验证规则
            valid: function (data) {
                let approveNodeData = data.properties
                // 返回 false 验证通过
                return false
            },
            handler: function (node, event) {
                var el = node.el;
                var data = node.data;
                $.ux.drawer({
                    title: '',
                    html: $.ux.template('tpl-review', node.data),
                    onok: function (e) {
                        if (e.button.className == "ajs-ok" && e.button.text == "确 定") {
                            let $form = $(".ajs-dialog form")
                            let workflowNodeName = $form.find("input[name='workflowNodeName']").val()//节点名称
                            let businessNodeId = $form.find("#businessNodeId option:selected").val()//业务模块
                            let businessNodeName = $form.find("#businessNodeId option:selected").text()//业务模块名称
                            let workflowNodeCheckType = $form.find("input[name='workflowNodeCheckType']:checked").val()//权限设置
                            let nodeBeforeReviewFlg = $form.find("input[name='nodeBeforeReviewFlg']:checked").val()//是否允许加签
                            let nodeModifyFlg = $form.find("input[name='nodeModifyFlg']:checked").val()//是否允许修改
                            let remark = $form.find("textarea[name='remark']").val()
                            let workflowInfoObj = {
                                workflowNodeName: workflowNodeName,
                                businessNodeId: businessNodeId,
                                businessNodeName: businessNodeName,
                                workflowNodeCheckType: workflowNodeCheckType,
                                nodeBeforeReviewFlg: nodeBeforeReviewFlg,
                                nodeModifyFlg: nodeModifyFlg,
                                remark: remark
                            }
                            if (commonJS.isEmpty(workflowNodeName)) {
                                layer.msg('请输入节点名称！', {
                                    icon: 5,
                                    zIndex: 1989202290,
                                    time: 1000
                                })
                                return false
                            }
                            if (commonJS.isEmpty(businessNodeId)) {
                                layer.msg('请选择业务模块！', {
                                    icon: 5,
                                    zIndex: 1989202290,
                                    time: 1000
                                })
                                return false
                            }
                            if (commonJS.isEmpty(workflowNodeCheckType)) {
                                layer.msg('请选择权限设置！', {
                                    icon: 5,
                                    zIndex: 1989202290,
                                    time: 1000
                                })
                                return false
                            }
                            let workflowNodeCheckIds = null, workflowNodeCheckIdsName = ''
                            let workflowNodeReviewProperty = []
                            let tagList = $form.find(".selectName").find(".tag");
                            if (workflowNodeCheckType == 1) {
                                //指定人员- 处理对象必选
                                for (let i = 0; i < tagList.length; i++) {
                                    let id = $($(tagList)[i]).attr("data-id")
                                    let name = $($(tagList)[i]).attr("data-name")
                                    let object = {
                                        workflowNodeCheckType: workflowNodeCheckType,
                                        workflowNodeCheckIds: id,
                                        workflowNodeCheckIdsName: name
                                    }
                                    workflowNodeReviewProperty.push(object);
                                    workflowNodeCheckIds = id
                                    workflowNodeCheckIdsName = name
                                }
                            }
                            if (workflowNodeCheckType == 3) {
                                // 指定角色-处理对象必选
                                for (let i = 0; i < tagList.length; i++) {
                                    let id = $($(tagList)[i]).attr("data-id")
                                    let name = $($(tagList)[i]).attr("data-name")
                                    let object = {
                                        workflowNodeCheckType: workflowNodeCheckType,
                                        workflowNodeCheckIds: id,
                                        workflowNodeCheckIdsName: name
                                    }
                                    workflowNodeReviewProperty.push(object);
                                    workflowNodeCheckIds = id
                                    workflowNodeCheckIdsName = name
                                }
                            }
                            if (workflowNodeCheckType == 4) {
                                // 指定部门-处理对象必选
                                for (let i = 0; i < tagList.length; i++) {
                                    let id = $($(tagList)[i]).attr("data-id")
                                    let name = $($(tagList)[i]).attr("data-name")
                                    let object = {
                                        workflowNodeCheckType: workflowNodeCheckType,
                                        workflowNodeCheckIds: id,
                                        workflowNodeCheckIdsName: name
                                    }
                                    workflowNodeReviewProperty.push(object);
                                    workflowNodeCheckIds = id
                                    workflowNodeCheckIdsName = name
                                }
                            }
                            if (workflowNodeCheckType == 5) {
                                let object = {
                                    workflowNodeCheckType: workflowNodeCheckType,
                                    workflowNodeCheckIds: $form.find("#customQX option:checked").val(),
                                    workflowNodeCheckIdsName: ""
                                }
                                workflowNodeReviewProperty.push(object);
                                workflowNodeCheckIds = $form.find("#customQX option:checked").val()
                            }
                            if (workflowNodeCheckType == 1 || workflowNodeCheckType == 3 || workflowNodeCheckType == 4) {
                                if (commonJS.isEmpty(workflowNodeCheckIds)) {
                                    layer.msg('请选择处理对象！', {
                                        icon: 5,
                                        zIndex: 1989202290,
                                        time: 1000
                                    })
                                    return false
                                }
                            } else if (workflowNodeCheckType == 2) {

                            } else {
                                if (commonJS.isEmpty(workflowNodeCheckIds)) {
                                    layer.msg('请选择自定义权限！', {
                                        icon: 5,
                                        zIndex: 1989202290,
                                        time: 1000
                                    })
                                    return false
                                }
                            }
                            workflowInfoObj.workflowNodeCheckIds = workflowNodeCheckIds
                            workflowInfoObj.workflowNodeCheckIdsName = workflowNodeCheckIdsName
                            workflowInfoObj.workflowNodeCheckUserList = workflowNodeReviewProperty
                            // 按钮设置校验必填
                            let btnSetList = [], flg = false
                            $('.buttonDiv').each((v, h) => {
                                let nodeButtonType = $(h).find(".nodeTypeClick:checked").val()//按钮类型
                                let nodeButtonId = $(h).find("input[name='nodeButtonId']").val()//按钮id
                                let nodeButtonName = $(h).find("input[name='btnName']").val()//按钮名称
                                let defaultEvent = $(h).find(".defaultEvent:checked").val()//默认事件
                                let transferWay = $(h).find(".selectNodeRadio:checked").val()//流转方式
                                let transferNodeId = $(h).find(".customNodeSelect option:selected").val()//指定节点
                                let transferNodeName = $(h).find(".customNodeSelect option:selected").text()//指定节点名称
                                let customEvent = $(h).find(".customEvent option:selected").val()//自定义事件
                                let obj = {
                                    nodeButtonType: nodeButtonType,
                                    nodeButtonId: nodeButtonId,
                                    nodeButtonName: nodeButtonName,
                                    defaultEvent: defaultEvent,
                                    customEvent: customEvent
                                }
                                if (defaultEvent == 0) {//流转方式为否
                                    obj.transferWay = transferWay
                                }
                                if (commonJS.isEmpty(nodeButtonId)) {
                                    layer.msg('请输入按钮id！', {
                                        icon: 5,
                                        zIndex: 1989202290,
                                        time: 1000
                                    })
                                    flg = true
                                    return false
                                }
                                if (commonJS.isEmpty(nodeButtonName)) {
                                    layer.msg('请输入按钮名称！', {
                                        icon: 5,
                                        zIndex: 1989202290,
                                        time: 1000
                                    })
                                    flg = true
                                    return false
                                }
                                if (transferWay == 3) {
                                    // 流转方式-指定节点
                                    if (commonJS.isEmpty(transferNodeId)) {
                                        layer.msg('请选择指定节点！', {
                                            icon: 5,
                                            zIndex: 1989202290,
                                            time: 1000
                                        })
                                        flg = true
                                        return false
                                    }
                                    obj.transferNodeId = transferNodeId
                                    obj.transferNodeName = transferNodeName
                                }
                                btnSetList.push(obj)
                            })
                            if (flg) {
                                return false
                            }
                            workflowInfoObj.btnSetList = btnSetList
                            workflow.setProperties(node.data, workflowInfoObj)
                            node.data.name = workflowNodeName
                            node.data.text = remark
                            workflow.setName(node, workflowNodeName)
                            workflow.setText(el, remark)
                            workflow.valid(node)
                        }
                    }
                }).set('width', 640)
                //加载默认数据
                //自定义权限、事件下拉
                getBean(1, data.properties.workflowNodeCheckIds)

                $("input[name='nodeIds']").val(data.nodeId)
                // 找出页面除了抄送和条件的所有节点
                getAllNodes(data.nodeId, null)
                // 赋值初始化
                let $form = $(".ajs-dialog form")
                $("input[name=workflowNodeName]").val(data.name)
                $("input[name=workflowNodeId]").val(data.nodeId)
                $("input[name=workflowId]").val(workflowInfo.workflowId)
                if (!$.isEmptyObject(data.properties)) {
                    if (data.properties.workflowNodeCheckType == 5) {
                        $('.customType').show()
                        $('.approveUser').hide()
                    } else if (data.properties.workflowNodeCheckType == 2) {
                        $('.customType').hide()
                        $('.approveUser').hide()
                    } else {
                        $('.customType').hide()
                        $('.approveUser').show()
                    }
                    $("input[name=remark]").val(data.properties.remark)
                    $form.find("input[name='workflowNodeName']").val(data.properties.workflowNodeName)//节点名称
                    $form.find("#businessNodeId").val(data.properties.businessNodeId)//业务模块
                    $form.find("input[name='workflowNodeCheckType'][value='" + data.properties.workflowNodeCheckType + "']").attr("checked", true)//权限设置
                    $form.find("input[name='nodeBeforeReviewFlg'][value='" + data.properties.nodeBeforeReviewFlg + "']").attr("checked", true)//是否允许加签
                    $form.find("input[name='nodeModifyFlg'][value='" + data.properties.nodeModifyFlg + "']").attr("checked", true)//是否允许修改
                    $form.find("textarea[name='remark']").val(data.properties.remark)
                    // 权限设置-处理对象
                    let infoList = data.properties.workflowNodeCheckUserList
                    if (data.properties.workflowNodeCheckType == 1) {
                        //指定人员- 处理对象必选
                        let htl = ``;
                        infoList.forEach((item, index) => {
                            htl += `<span class="tag" data-id="${item.workflowNodeCheckIds}" data-name="${item.workflowNodeCheckIdsName}">${item.workflowNodeCheckIdsName}<span style="color: red;margin-left: 5px;cursor:pointer;" onclick="delTags(this)">x</span></span>`
                        })
                        $form.find('.selectName').html(htl)
                    }
                    if (data.properties.workflowNodeCheckType == 3) {
                        // 指定角色-处理对象必选
                        let htl = ``;
                        infoList.forEach((item, index) => {
                            htl += `<span class="tag" data-id="${item.workflowNodeCheckIds}" data-name="${item.workflowNodeCheckIdsName}">${item.workflowNodeCheckIdsName}<span style="color: red;margin-left: 5px;cursor:pointer;" onclick="delTags(this)">x</span></span>`
                        })
                        $form.find('.selectName').html(htl)
                    }
                    if (data.properties.workflowNodeCheckType == 4) {
                        // 指定部门-处理对象必选
                        let htl = ``;
                        infoList.forEach((item, index) => {
                            htl += `<span class="tag" data-id="${item.workflowNodeCheckIds}" data-name="${item.workflowNodeCheckIdsName}">${item.workflowNodeCheckIdsName}<span style="color: red;margin-left: 5px;cursor:pointer;" onclick="delTags(this)">x</span></span>`
                        })
                        $form.find('.selectName').html(htl)
                    }
                    if (data.properties.workflowNodeCheckType == 5) {
                        $form.find('#customQX').val(data.properties.workflowNodeCheckIds)
                    }
                    // 按钮设置赋值
                    // 获取按钮中按钮类型已经选中了哪些
                    let hasSelectedArr = []
                    $('.allBtnContainer').empty()
                    if (data.properties.btnSetList && data.properties.btnSetList.length > 0) {
                        data.properties.btnSetList.forEach(item => {
                            hasSelectedArr.push(item.nodeButtonType)
                        })
                        let disabledA = false, disabledB = false, disabledC = false
                        if (hasSelectedArr.indexOf('1') != -1) {
                            disabledA = true
                        }
                        if (hasSelectedArr.indexOf('2') != -1) {
                            disabledB = true
                        }
                        if (hasSelectedArr.indexOf('3') != -1) {
                            disabledC = true
                        }
                        let html = ''
                        data.properties.btnSetList.forEach((item, index) => {
                            let numbers = Math.floor(Math.random() * (9999 - 1000)) + 1000
                            html += `<input type="hidden" id="nodeIds" value="${data.nodeId}"><dl class="buttonDiv">
                                <i class="layui-icon layui-icon-close delBtn"></i>
                                <div class="first">
                                    <dt><span class="fc-star">*</span>按钮类型：</dt>
                                    <dd style="flex: auto;"  class="radioLine" data-oldvalue="${item.nodeButtonType}">
                                        <label class="fc-group">
                                            <input type="radio" name="nodeButtonType${index}" value="1" ${item.nodeButtonType == 1 ? 'checked' : ''} ${item.nodeButtonType != 1 && disabledA ? 'disabled' : ''} class="nodeTypeClick"/>通过</label>
                                        <label class="fc-group">
                                            <input type="radio" name="nodeButtonType${index}" value="2" ${item.nodeButtonType == 2 ? 'checked' : ''} ${item.nodeButtonType != 2 && disabledB ? 'disabled' : ''} class="nodeTypeClick"/>退回</label>
                                        <label class="fc-group">
                                            <input type="radio" name="nodeButtonType${index}" value="3" ${item.nodeButtonType == 3 ? 'checked' : ''} ${item.nodeButtonType != 3 && disabledC ? 'disabled' : ''} class="nodeTypeClick"/>拒绝</label>
                                        <label class="fc-group">
                                            <input type="radio" name="nodeButtonType${index}" value="4" ${item.nodeButtonType == 4 ? 'checked' : ''} class="nodeTypeClick"/>自定义</label>
                                    </dd>
                                </div>
                                <div>
                                    <dt><span class="fc-star">*</span>按钮id：</dt>
                                    <dd class="fc-form-inline">
                                        <input type="text" name="nodeButtonId" autocomplete="off" value="${item.nodeButtonId}" placeholder="请输入按钮id" onkeyup="value=value.replace(/[^a-zA-Z0-9]/g,'')" class="fc-ipt fc-ipt-auto btnidBlur">
                                    </dd>
                                </div>
                                <div class="second">
                                    <dt><span class="fc-star">*</span>按钮名称：</dt>
                                    <dd class="fc-form-inline">
                                        <input type="text" name="btnName" value="${item.nodeButtonName}" autocomplete="off" placeholder="请输入按钮名称"
                                               class="fc-ipt fc-ipt-auto">
                                    </dd>
                                </div>
                                <div class="third defaultRadio ${item.nodeButtonType == 4 ? 'fc-hide' : ''}">
                                    <dt><span class="fc-star">*</span>默认事件：</dt>
                                    <dd style="flex: auto;">
                                        <label class="fc-group">
                                            <input type="radio" name="defaultEvent${index}" value="0" ${item.defaultEvent == 0 ? 'checked' : ''} class="defaultEvent" />否</label>
                                        <label class="fc-group">
                                            <input type="radio" name="defaultEvent${index}" value="1" ${item.defaultEvent == 1 ? 'checked' : ''} class="defaultEvent" />是</label>
                                    </dd>
                                </div>
                                <div class="fourth ${item.defaultEvent == 0 || item.nodeButtonType == 4 ? '' : 'fc-hide'} liuzhuanBox">
                                    <dt><span class="fc-star">*</span>流转方式：</dt>
                                    <dd style="flex: auto;">
                                        <label class="fc-group">
                                            <input type="radio" name="transferWay${numbers}" value="1" ${item.transferWay == 1 ? 'checked' : ''} class="selectNodeRadio"/>下一节点</label>
                                        <label class="fc-group">
                                            <input type="radio" name="transferWay${numbers}" value="2" ${item.transferWay == 2 ? 'checked' : ''} class="selectNodeRadio"/>上一节点</label>
                                        <label class="fc-group">
                                            <input type="radio" name="transferWay${numbers}" value="3" ${item.transferWay == 3 ? 'checked' : ''} ${nodesAlls && 0 == nodesAlls.length ? 'disabled' : ''} class="selectNodeRadio"/>指定节点</label>
                                    </dd>
                                </div>`
                            if (item.transferWay == "3") {
                                html += `<div class="customNodeSelectLine">`
                            } else {
                                html += `<div class="customNodeSelectLine fc-hide">`
                            }
                            html += `<dt><span class="fc-star">*</span>指定节点：</dt>
                                    <dd style="flex: auto;">
                                        <select class="customNodeSelect">`
                            if (nodesAlls.length > 0) {
                                html += '<option value="">请选择</option>'
                                nodesAlls.forEach(x => {
                                    if (x.nodeId == item.transferNodeId) {
                                        html += `<option value="${x.nodeId}" selected>${x.nodeName}</option>`
                                    } else {
                                        html += `<option value="${x.nodeId}">${x.nodeName}</option>`
                                    }
                                })
                            } else {
                                html += '<option value="">暂无选项</option>'
                            }
                            html += `</select>
                                    </dd>
                                </div>
                                <div>
                                    <dt>自定义事件：</dt>
                                    <dd style="flex: auto;"><select class="customEvent">`
                            html += `<option value="">请选择</option>`
                            if (beanEventList && beanEventList.length > 0) {
                                beanEventList.forEach(subItem => {
                                    html += `<option value="${subItem}" ${item.customEvent == subItem ? 'selected' : ''}>${subItem}</option>`
                                })
                            } else {
                                html += `<option value="">暂无选项</option>`
                            }
                            html += `</select>
                                    </dd>
                                </div>
                            </dl>`
                        })
                        $('.allBtnContainer').append(html)
                    }
                }

                if ($.isEmptyObject(data.properties)) {
                    getBean(2, null)
                }
                // 查业务模块下拉
                getBussinessList(workflowInfo.workflowBusiness, data.properties)
                initClick()
            }
        },
            {
                type: 'notifier',
                icon: 'send',
                text: '抄送节点',
                color: 'green',
                node: {
                    tips: '抄送',
                    icon: 'send',
                    name: '',
                    color: 'green', // 定义不同色块(blue/green/orange)，也支持色值(#b99a01)
                    text: '请配置抄送节点', // 也支持function，this指向 properties
                },
                // 自定义非空验证规则
                valid: function (data) {
                    // 返回 false 验证通过
                    return false
                },
                handler: function (node, event) {
                    var el = node.el;
                    var data = node.data;
                    //初始化自定义权限
                    getNotifier()

                    $.ux.drawer({
                        title: '',
                        html: $.ux.template('tpl-copyFor', node.data),
                        onok: function (e) {
                            let $form = $(".ajs-dialog form")
                            if (e.button.className == "ajs-ok" && e.button.text == "确 定") {
                                let $form = $(".ajs-dialog form")
                                let workflowNodeName = $form.find("input[name='workflowNodeName']").val()//节点名称
                                let workflowNodeCheckType = $form.find("input[name='workflowNodeCheckType']:checked").val()//抄送类型
                                let remark = $form.find("textarea[name='remark']").val()//备注
                                let workflowInfoObj = {
                                    workflowNodeName: workflowNodeName,
                                    workflowNodeCheckType: workflowNodeCheckType,
                                    remark: remark
                                }
                                let workflowNodeReviewProperty = []
                                if (commonJS.isEmpty(workflowNodeName)) {
                                    layer.msg('请输入节点名称！', {
                                        icon: 5,
                                        zIndex: 1989202290,
                                        time: 1000
                                    })
                                    return false
                                }
                                if (commonJS.isEmpty(workflowNodeCheckType)) {
                                    layer.msg('请选择抄送类型！', {
                                        icon: 5,
                                        zIndex: 1989202290,
                                        time: 1000
                                    })
                                    return false
                                }
                                let workflowNodeCheckIds = null, workflowNodeCheckIdsName = ''
                                let tagList = $form.find(".selectName").find(".tag");
                                if (workflowNodeCheckType == 1) {
                                    //指定人员- 处理对象必选
                                    // workflowNodeCheckIds = $form.find("input[name=userId]").val()
                                    // workflowNodeCheckIdsName = $form.find("input[name=userName]").val()
                                    for (let i = 0; i < tagList.length; i++) {
                                        let id = $($(tagList)[i]).attr("data-id")
                                        let name = $($(tagList)[i]).attr("data-name")
                                        let object = {
                                            workflowNodeCheckType: workflowNodeCheckType,
                                            workflowNodeCheckIds: id,
                                            workflowNodeCheckIdsName: name
                                        }
                                        workflowNodeReviewProperty.push(object);
                                        workflowNodeCheckIds = id
                                        workflowNodeCheckIdsName = name
                                    }
                                }
                                if (workflowNodeCheckType == 3) {
                                    // 指定角色-处理对象必选
                                    // workflowNodeCheckIds = $form.find("input[name=roleId]").val()
                                    // workflowNodeCheckIdsName = $form.find("input[name=roleName]").val()
                                    for (let i = 0; i < tagList.length; i++) {
                                        let id = $($(tagList)[i]).attr("data-id")
                                        let name = $($(tagList)[i]).attr("data-name")
                                        let object = {
                                            workflowNodeCheckType: workflowNodeCheckType,
                                            workflowNodeCheckIds: id,
                                            workflowNodeCheckIdsName: name
                                        }
                                        workflowNodeReviewProperty.push(object);
                                        workflowNodeCheckIds = id
                                        workflowNodeCheckIdsName = name
                                    }
                                }
                                if (workflowNodeCheckType == 4) {
                                    // 指定部门-处理对象必选
                                    // workflowNodeCheckIds = $form.find("input[name=deptId]").val()
                                    // workflowNodeCheckIdsName = $form.find("input[name=deptName]").val()
                                    for (let i = 0; i < tagList.length; i++) {
                                        let id = $($(tagList)[i]).attr("data-id")
                                        let name = $($(tagList)[i]).attr("data-name")
                                        let object = {
                                            workflowNodeCheckType: workflowNodeCheckType,
                                            workflowNodeCheckIds: id,
                                            workflowNodeCheckIdsName: name
                                        }
                                        workflowNodeReviewProperty.push(object);
                                        workflowNodeCheckIds = id
                                        workflowNodeCheckIdsName = name
                                    }
                                }
                                if (workflowNodeCheckType == 5) {
                                    let object = {
                                        workflowNodeCheckType: workflowNodeCheckType,
                                        workflowNodeCheckIds: $form.find("#notifierQX option:checked").val(),
                                        workflowNodeCheckIdsName: ""
                                    }
                                    workflowNodeReviewProperty.push(object);
                                    workflowNodeCheckIds = $form.find("#notifierQX option:checked").val()
                                }
                                if (workflowNodeCheckType == 1 || workflowNodeCheckType == 3 || workflowNodeCheckType == 4) {
                                    if (commonJS.isEmpty(workflowNodeCheckIds)) {
                                        layer.msg('请选择处理对象！', {
                                            icon: 5,
                                            zIndex: 1989202290,
                                            time: 1000
                                        })
                                        return false
                                    }
                                } else if (workflowNodeCheckType == 2) {

                                } else {
                                    if (commonJS.isEmpty(workflowNodeCheckIds)) {
                                        layer.msg('请选择自定义权限！', {
                                            icon: 5,
                                            zIndex: 1989202290,
                                            time: 1000
                                        })
                                        return false
                                    }
                                }
                                workflowInfoObj.workflowNodeCheckIds = workflowNodeCheckIds
                                workflowInfoObj.workflowNodeCheckIdsName = workflowNodeCheckIdsName
                                workflowInfoObj.workflowNodeCheckUserList = workflowNodeReviewProperty
                                workflow.setProperties(node.data, workflowInfoObj)
                                node.data.name = workflowNodeName
                                node.data.text = remark
                                workflow.setName(node, workflowNodeName)
                                workflow.setText(el, remark)
                                workflow.valid(node)
                            }
                        }
                    }).set('width', 640)
                    //加载默认数据
                    let $form = $(".ajs-dialog form")
                    if (!$.isEmptyObject(data.properties)) {
                        if (data.properties.workflowNodeCheckType == 1 || data.properties.workflowNodeCheckType == 3 || data.properties.workflowNodeCheckType == 4) {
                            $('.notifierType').hide()
                            $('.notifieUser').show()
                        } else if (data.properties.workflowNodeCheckType == 2) {
                            $('.notifierType').hide()
                            $('.notifieUser').hide()
                        } else if (data.properties.workflowNodeCheckType == 5) {
                            $('.notifieUser').hide()
                            $('.notifierType').show()
                        }
                        $form.find("input[name='workflowNodeName']").val(data.properties.workflowNodeName)//节点名称
                        $form.find("input[name='workflowNodeCheckType'][value='" + data.properties.workflowNodeCheckType + "']").attr("checked", true)//抄送类型
                        $form.find("textarea[name='remark']").val(data.properties.remark)
                        // 权限设置-处理对象
                        let infoList = data.properties.workflowNodeCheckUserList
                        if (data.properties.workflowNodeCheckType == 1) {
                            //指定人员- 处理对象必选
                            //指定人员- 处理对象必选
                            let htl = ``;
                            infoList.forEach((item, index) => {
                                htl += `<span class="tag" data-id="${item.workflowNodeCheckIds}" data-name="${item.workflowNodeCheckIdsName}">${item.workflowNodeCheckIdsName}<span style="color: red;margin-left: 5px;cursor:pointer;" onclick="delTags(this)">x</span></span>`
                            })
                            $form.find('.selectName').html(htl)
                        }
                        if (data.properties.workflowNodeCheckType == 3) {
                            // 指定角色-处理对象必选
                            let htl = ``;
                            infoList.forEach((item, index) => {
                                htl += `<span class="tag" data-id="${item.workflowNodeCheckIds}" data-name="${item.workflowNodeCheckIdsName}">${item.workflowNodeCheckIdsName}<span style="color: red;margin-left: 5px;cursor:pointer;" onclick="delTags(this)">x</span></span>`
                            })
                            $form.find('.selectName').html(htl)
                        }
                        if (data.properties.workflowNodeCheckType == 4) {
                            // 指定部门-处理对象必选
                            let htl = ``;
                            infoList.forEach((item, index) => {
                                htl += `<span class="tag" data-id="${item.workflowNodeCheckIds}" data-name="${item.workflowNodeCheckIdsName}">${item.workflowNodeCheckIdsName}<span style="color: red;margin-left: 5px;cursor:pointer;" onclick="delTags(this)">x</span></span>`
                            })
                            $form.find('.selectName').html(htl)
                        }
                        if (data.properties.workflowNodeCheckType == 5) {
                            $form.find('#notifierQX').val(data.properties.workflowNodeCheckIds)
                            getNotifier(data.properties.workflowNodeCheckIds)
                        }

                    }
                }
            },
            {
                type: 'condition',
                icon: 'sitemap',
                text: '条件分支',
                handler: function (node, event) {
                    var el = node.el;
                    var data = node.data;
                    $.ux.drawer({
                        title: '',
                        html: $.ux.template('tpl-condition', node.data),
                        onshow: function () {
                            let $form = $(".ajs-dialog form")
                            $form.find(".condition-form-field").hide()
                        },
                        onok: function (e) {
                            let $form = $(".ajs-dialog form")
                            if (e.button.className == "ajs-ok" && e.button.text == "确 定") {
                                let workflowNodeName = $form.find("input[name='workflowNodeName']").val()
                                let remark = $form.find("textarea[name='remark']").val()//备注
                                if (commonJS.isEmpty(workflowNodeName)) {
                                    layer.msg('请输入节点名称！', {
                                        icon: 5,
                                        zIndex: 1989202290,
                                        time: 1000
                                    })
                                    return false
                                }
                                if (commonJS.isEmpty($form.find("input[name='workflowNodeTransOrder']").val())) {
                                    layer.msg('请输入优先级！', {
                                        icon: 5,
                                        zIndex: 1989202290,
                                        time: 1000
                                    })
                                    return false
                                }
                                if (commonJS.isEmpty($form.find("input[name=workflowNodeTransType]:checked").val())) {
                                    layer.msg('请选择条件关系！', {
                                        icon: 5,
                                        zIndex: 1989202290,
                                        time: 1000
                                    })
                                    return false
                                }
                                let workflowInfoObj = {
                                    workflowNodeName: workflowNodeName,
                                    workflowNodeTransOrder: $form.find("input[name='workflowNodeTransOrder']").val(),
                                    workflowNodeTransType: $form.find("input[name=workflowNodeTransType]:checked").val(),
                                    remark: remark
                                }
                                let workflowNodeTransConditionList = [];
                                let flgs = false;
                                $('.conditionDiv').each((v, h) => {
                                    let newObj = {
                                        workflowNodeTransOrder: $form.find("input[name='workflowNodeTransOrder']").val(),
                                        workflowNodeTransType: $form.find("input[name=workflowNodeTransType]:checked").val(),
                                    }
                                    let conditionType = $(h).find(".first").find("input[type='radio']:checked").val()
                                    let obj = {
                                        conditionType: conditionType
                                    }
                                    if (commonJS.isEmpty(conditionType)) {
                                        layer.msg('请选择条件类型！', {
                                            icon: 5,
                                            zIndex: 1989202290,
                                            time: 1000
                                        })
                                        flgs = true;
                                        return false
                                    }
                                    let tagList = $(h).find(".selectName").find(".tag");
                                    if (conditionType == "1") {
                                        let onlyList = [];
                                        let isNotNullId = "";
                                        for (let i = 0; i < tagList.length; i++) {
                                            let id = $($(tagList)[i]).attr("data-id")
                                            let name = $($(tagList)[i]).attr("data-name")
                                            let only = {
                                                conditionType: conditionType,
                                                conditionKey: id,
                                                conditionKeyName: name,
                                                conditionOperation: $(h).find(".third").find("input[type='radio']:checked").val()
                                            };
                                            onlyList.push(only)
                                            isNotNullId = id;
                                        }
                                        newObj.workflowNodeTransConditions = onlyList
                                        if (commonJS.isEmpty(isNotNullId)) {
                                            layer.msg('请选择条件筛选！', {
                                                icon: 5,
                                                zIndex: 1989202290,
                                                time: 1000
                                            })
                                            flgs = true;
                                            return false
                                        }
                                        if (commonJS.isEmpty($(h).find(".third").find("input[type='radio']:checked").val())) {
                                            layer.msg('请选择条件公式！', {
                                                icon: 5,
                                                zIndex: 1989202290,
                                                time: 1000
                                            })
                                            flgs = true;
                                            return false
                                        }
                                    } else if (conditionType == "2") {
                                        let onlyList = [];
                                        let isNotNullId = "";
                                        for (let i = 0; i < tagList.length; i++) {
                                            let id = $($(tagList)[i]).attr("data-id")
                                            let name = $($(tagList)[i]).attr("data-name")
                                            let only = {
                                                conditionType: conditionType,
                                                conditionKey: id,
                                                conditionKeyName: name,
                                                conditionOperation: $(h).find(".third").find("input[type='radio']:checked").val()
                                            };
                                            onlyList.push(only)
                                            isNotNullId = id;
                                        }
                                        newObj.workflowNodeTransConditions = onlyList
                                        if (commonJS.isEmpty(isNotNullId)) {
                                            layer.msg('请选择条件筛选！', {
                                                icon: 5,
                                                zIndex: 1989202290,
                                                time: 1000
                                            })
                                            flgs = true;
                                            return false
                                        }
                                        if (commonJS.isEmpty($(h).find(".third").find("input[type='radio']:checked").val())) {
                                            layer.msg('请选择条件公式！', {
                                                icon: 5,
                                                zIndex: 1989202290,
                                                time: 1000
                                            })
                                            flgs = true;
                                            return false
                                        }
                                    } else if (conditionType == "3") {
                                        if (commonJS.isEmpty($(h).find(".lastLevel option:selected").val())) {
                                            layer.msg('请选择操作按钮！', {
                                                icon: 5,
                                                zIndex: 1989202290,
                                                time: 1000
                                            })
                                            flgs = true;
                                            return false
                                        }
                                        let onlyList = [];
                                        let only = {
                                            conditionType: conditionType,
                                            conditionKey: $(h).find(".lastLevel option:selected").val(),
                                            conditionKeyName: "",
                                            conditionOperation: $(h).find(".third").find("input[type='radio']:checked").val()
                                        };
                                        onlyList.push(only)
                                        newObj.workflowNodeTransConditions = onlyList
                                    } else if (conditionType == "4") {
                                        if (commonJS.isEmpty($(h).find(".custom option:selected").val())) {
                                            layer.msg('请选择自定义！', {
                                                icon: 5,
                                                zIndex: 1989202290,
                                                time: 1000
                                            })
                                            flgs = true;
                                            return false
                                        }
                                        let onlyList = [];
                                        let only = {
                                            conditionType: conditionType,
                                            conditionKey: $(h).find(".custom option:selected").val(),
                                            conditionKeyName: "",
                                            conditionOperation: $(h).find(".third").find("input[type='radio']:checked").val()
                                        };
                                        onlyList.push(only)
                                        newObj.workflowNodeTransConditions = onlyList
                                    } else if (conditionType == "5") {
                                        if (commonJS.isEmpty($(h).find(".sameSelect  option:selected").val())) {
                                            layer.msg('请选择业务表！', {
                                                icon: 5,
                                                zIndex: 1989202290,
                                                time: 1000
                                            })
                                            flgs = true;
                                            return false
                                        }
                                        if (commonJS.isEmpty($(h).find(".tableNameSelectChild option:selected").val())) {
                                            layer.msg('请选择表字段！', {
                                                icon: 5,
                                                zIndex: 1989202290,
                                                time: 1000
                                            })
                                            flgs = true;
                                            return false
                                        }
                                        if (commonJS.isEmpty($(h).find(".five").find("input[type='radio']:checked").val())) {
                                            layer.msg('请选择条件公式！', {
                                                icon: 5,
                                                zIndex: 1989202290,
                                                time: 1000
                                            })
                                            flgs = true;
                                            return false
                                        }
                                        if (commonJS.isEmpty($(h).find(".six").find("input").val())) {
                                            layer.msg('请输入对比值！', {
                                                icon: 5,
                                                zIndex: 1989202290,
                                                time: 1000
                                            })
                                            flgs = true;
                                            return false
                                        }
                                        let onlyList = [];
                                        let only = {
                                            conditionType: conditionType,
                                            businessTable: $(h).find(".sameSelect  option:selected").val(),
                                            conditionKey: $(h).find(".tableNameSelectChild option:selected").val(),
                                            conditionKeyName: "",
                                            conditionOperation: $(h).find(".five").find("input[type='radio']:checked").val(),
                                            conditionValue: $(h).find(".six").find("input").val()
                                        };
                                        onlyList.push(only)
                                        newObj.workflowNodeTransConditions = onlyList
                                    }
                                    workflowNodeTransConditionList.push(newObj)
                                })
                                if (!flgs) {
                                    workflowInfoObj.workflowNodeTransConditionList = workflowNodeTransConditionList
                                    workflow.setProperties(node.data, workflowInfoObj)
                                    node.data.name = workflowNodeName
                                    node.data.text = remark
                                    workflow.setName(node, workflowNodeName)
                                    workflow.setText(el, remark)
                                    workflow.valid(node)
                                } else {
                                    return false;
                                }
                            }
                        }
                    }).set('width', 640)
                    branchNode = data.nodeId
                    getLast(branchNode, null)
                    getTableNameList()
                    getBranch()
                    //回写值
                    let $form = $(".ajs-dialog form")
                    if (!$.isEmptyObject(data.properties)) {
                        $form.find("input[name='workflowNodeName']").val(data.properties.workflowNodeName)//节点名称
                        $form.find("input[name='workflowNodeTransOrder']").val(data.properties.workflowNodeTransOrder)//优先级
                        $form.find("input[name='workflowNodeTransType'][value='" + data.properties.workflowNodeTransType + "']").attr("checked", true)//条件关系
                        let remark = $form.find("textarea[name='remark']").val(data.properties.remark)//备注
                        $("#conditionDivs").empty()
                        let htl = ``;
                        if (null != data.properties.workflowNodeTransConditionList && data.properties.workflowNodeTransConditionList.length > 0) {
                            data.properties.workflowNodeTransConditionList.forEach((subItem, index) => {
                                let spanHtl = ``;
                                let conditionOperation = "";
                                let conditionType = "";
                                let conditionKey = "";
                                if (subItem.workflowNodeTransConditions && subItem.workflowNodeTransConditions.length > 0) {
                                    conditionKey = subItem.workflowNodeTransConditions[0].conditionKey
                                    conditionOperation = subItem.workflowNodeTransConditions[0].conditionOperation
                                    conditionType = subItem.workflowNodeTransConditions[0].conditionType
                                    businessTable = subItem.workflowNodeTransConditions[0].businessTable
                                    conditionValue = subItem.workflowNodeTransConditions[0].conditionValue
                                    subItem.workflowNodeTransConditions.forEach((items, index) => {
                                        spanHtl += `<span class="tag" data-id="${items.conditionKey}" data-name="${items.conditionKeyName}">${items.conditionKeyName}<span style="color: red;margin-left: 5px;cursor:pointer;" onclick="delTags(this)">x</span></span>`
                                    })
                                }
                                htl += `<dl class="conditionDiv">
                                            <i class="layui-icon layui-icon-close conditionBtn"></i>
                                                <div class="first">
                                                    <dt><span class="fc-star">*</span>条件类型：</dt>
                                                     <dd style="flex: auto;">
                                                         <label class="fc-group">
                                                            <input type="radio" name="conditionType${index}" value="1" data-type="4" ${conditionType == 1 ? 'checked' : ''} onclick="workflowConditionTypes(this)"/>
                                                            发起人部门
                                                         </label>
                                                        <label class="fc-group">
                                                            <input type="radio" name="conditionType${index}" value="2" data-type="3" ${conditionType == 2 ? 'checked' : ''}  onclick="workflowConditionTypes(this)"/>
                                                            发起人角色
                                                        </label>
                                                        <label class="fc-group">
                                                            <input type="radio" name="conditionType${index}" value="3" data-type="1" ${conditionType == 3 ? 'checked' : ''} ${lastNodes.length == 0 ? 'disabled' : ''}  onclick="workflowConditionTypes(this)"/>
                                                         上一级操作
                                                        </label>
                                                        <label class="fc-group">
                                                            <input type="radio" name="conditionType${index}" value="4" data-type="2" ${conditionType == 4 ? 'checked' : ''}  onclick="workflowConditionTypes(this)"/>
                                                        自定义
                                                         </label>
                                                         <br/>
                                                         <br/>
                                                         <label class="fc-group" style="margin-left: 0;">
                                                             <input type="radio" name="conditionType${index}" value="5" data-type="5" ${conditionType == 5 ? 'checked' : ''} onclick="workflowConditionTypes(this)"/>
                                                             业务字段
                                                         </label>
                                                     </dd>
                                                </div>`
                                htl += `<div class="second screen" style="${(conditionType == 1 || conditionType == 2) ? '' : 'display:none'}">
                                                    <dt><span class="fc-star">*</span>条件筛选：</dt>
                                                    <dd style="display: flex;align-items: center">
                                                        <div style="margin-top: 0;" class="selectName">${spanHtl}</div>
                                                        <button type="button" name="addApproveUser" plain="" class="layui-btn layui-btn-primary layui-border-blue layui-btn-sm" onclick="selConditionUser(this)">
                                                            <i class="layui-icon layui-icon-add-1"></i>
                                                        选择
                                                        </button>
                                                    </dd>
                                                </div>
                                                <div class="third formual" style="${(conditionType == 1 || conditionType == 2) ? '' : 'display:none'}">
                                                    <dt><span class="fc-star">*</span>条件公式：</dt>
                                                    <dd style="flex: auto;">
                                                        <label class="fc-group">
                                                            <input type="radio" name="conditionOperation${index}" value="1" ${conditionOperation == 1 ? 'checked' : ''}/>
                                                            属于
                                                        </label>
                                                        <label class="fc-group">
                                                            <input type="radio" name="conditionOperation${index}" value="2" ${conditionOperation == 2 ? 'checked' : ''}/>
                                                            不属于
                                                        </label>
                                                    </dd>
                                                </div>`
                                htl += `<div class="lastLevel" style="${conditionType == 3 ? '' : 'display:none'}">
                                                    <dt><span class="fc-star">*</span>操作按钮：</dt>
                                                    <dd>
                                                        <select class="lastNode">`
                                htl += '<option value="">请选择</option>'
                                if (lastNodes && lastNodes.length > 0) {
                                    lastNodes.forEach(item => {
                                        htl += `<option value="${item.nodeButtonId}" ${item.nodeButtonId == conditionKey ? 'selected' : ''}>${item.nodeButtonName}</option>`
                                    })
                                }
                                htl += `</select></dd></div>`
                                htl += `<div class="custom" style="${conditionType == 4 ? '' : 'display:none'}">
                                                    <dt><span class="fc-star">*</span>自定义：</dt>
                                                    <dd>
                                                        <select>`
                                htl += '<option value="">请选择</option>'
                                if (branchList && branchList.length > 0) {
                                    branchList.forEach(item => {
                                        htl += `<option value="${item}" ${item == conditionKey ? 'selected' : ''}>${item}</option>`
                                    })
                                }
                                htl += `</select></dd></div>`
                                htl += `<div class="tableNames" style="${conditionType == 5 ? '' : 'display:none'}">
                                        <dt><span class="fc-star">*</span>业务表：</dt>
                                        <dd>
                                            <select class="tableNameSelect${index} sameSelect" onchange="tableNameSelectChange(this)">
                                            <option value="">请选择</option>`
                                if (tableNameList && tableNameList.length > 0) {
                                    tableNameList.forEach(item => {
                                        htl += `<option value="${item.TABLE_NAME}" ${item.TABLE_NAME == businessTable ? 'selected' : ''}>${item.COMMENTS}</option>`
                                        selectMap.set(".tableNameSelect" + index, {
                                            conditionKey: conditionKey,
                                            businessTable: businessTable
                                        })
                                    })
                                }
                                htl += `</select>
                                        </dd>
                                    </div>
                                    <div class="tableNameSelects" style="${conditionType == 5 ? '' : 'display:none'}">
                                        <dt><span class="fc-star">*</span>表字段：</dt>
                                        <dd>
                                            <select class="tableNameSelectChild">
                                             </select>
                                        </dd>
                                    </div>`
                                htl += `<div class="five" style="${conditionType == 5 ? '' : 'display:none'}">
                                    <dt><span class="fc-star">*</span>条件公式：</dt>
                                    <dd style="flex: auto;">
                                    <label class="fc-group"><input type="radio" name="conditionOperationLast${index}" value="1"  ${conditionOperation == 1 ? 'checked' : ''}/>属于</label>
                                    <label class="fc-group"><input type="radio" name="conditionOperationLast${index}" value="2" ${conditionOperation == 2 ? 'checked' : ''}/>不属于</label>
                                    <label class="fc-group"><input type="radio" name="conditionOperationLast${index}" value="3" ${conditionOperation == 3 ? 'checked' : ''}/>大于</label>
                                    <label class="fc-group"><input type="radio" name="conditionOperationLast${index}" value="4" ${conditionOperation == 4 ? 'checked' : ''}/>大于等于</label>
                                    <label class="fc-group"><input type="radio" name="conditionOperationLast${index}" value="5" ${conditionOperation == 5 ? 'checked' : ''}/>小于</label>
                                    <label class="fc-group"><input type="radio" name="conditionOperationLast${index}" value="6" ${conditionOperation == 6 ? 'checked' : ''}/>小于等于</label>
                                    </dd></div>`
                                htl += `<div class="six" style="${conditionType == 5 ? '' : 'display:none'}">
                                         <dt><span class="fc-star">*</span>对比值：</dt>
                                         <dd style="flex: auto;">
                                         <label class="fc-group"><input type="text" name="conditionValue" value="${conditionValue}" placeholder="请输入对比值"/></label>
                                         </dd>
                                       </div>`
                                htl += `</dl>`;
                            })
                        }
                        $("#conditionDivs").append(htl)
                        initTableNameSelectInfo()
                    }
                }
            }],
    })

    // 流程回显
    if (workflowInfo && workflowInfo.workflowJson) {
        let workflowDesignJson = JSON.parse(workflowInfo.workflowJson)
        if (workflowDesignJson.hasOwnProperty("childNode")) {
            workflow.load(JSON.parse(workflowInfo.workflowJson))
        }
        getBean(1, null);
        getBean(2, null);
    }

    form.on('submit(workflowInfo-edit-form-submit)', function (data) {

        //流程设计信息
        let workflowDesignJson = null

        if (workflow.validAll()) {
            workflowDesignJson = workflow.getJson()
        } else {
            layer.msg("请检查各个节点是否全部配置完善", {icon: 3, time: 1000});
            return false
        }
        let workflowInfos = {
            workflowId: workflowInfo.workflowId,
            tenantId: workflowInfo.tenantId,
            workflowJson: workflowDesignJson
        }
        let workflowSaveRequest = {
            workflowInfo: workflowInfos
        }
        febs.postArray(ctx + 'workflowInfo/save', workflowSaveRequest, function (r) {
            if (r.code == "200") {
                layer.msg("保存成功", {icon: 1, time: 1000}, function () {
                    layer.closeAll();
                });
            } else {
                layer.msg("保存失败", {icon: 2, time: 1000});
            }
        });
        //addOrUpdate(data.field);
        return false;
    });

    function addOrUpdate(data) {

    }

    var beanEventList = []

    function getBean(beanType, selectVal) {
        febs.get(ctx + 'workflowNode/queryWorkflowCustomBean', {classType: beanType}, function (res) {
            if (res.code === 200) {
                let html = '<option value="">请选择</option>'
                if (res.data && res.data.length > 0) {
                    res.data.forEach(item => {
                        html += `<option value="${item}">${item}</option>`
                    })
                } else {
                    html = `<option value="暂无选项">暂无选项</option>`
                }
                if (beanType == 1) {
                    $('#customQX').empty()
                    $('#customQX').append(html)
                    if (selectVal) {
                        $('#customQX').val(selectVal)
                    }
                } else {
                    $('.customEvent').empty()
                    $('.customEvent').append(html)
                    beanEventList = res.data
                }
            }
        });
    }

    window.addBtn = function (datas) {
        let index = $('.buttonDiv').length + 1
        let selectedType = []
        let allLine = $('.radioLine')

        for (let key in allLine) {
            if (typeof key == 'string' && !isNaN(Number(key))) {
                selectedType.push($(allLine[key]).attr('data-oldvalue'))
            }
        }
        let disabledA = false, disabledB = false, disabledC = false
        if (selectedType.indexOf('1') != -1) {
            disabledA = true
        }
        if (selectedType.indexOf('2') != -1) {
            disabledB = true
        }
        if (selectedType.indexOf('3') != -1) {
            disabledC = true
        }
        let html = `<dl class="buttonDiv">
                <i class="layui-icon layui-icon-close delBtn"></i>
                <div>
                    <dt><span class="fc-star">*</span>按钮类型：</dt>
                    <dd style="flex: auto;" class="radioLine" data-oldvalue="4">
                        <label class="fc-group">
                            <input type="radio" name="nodeButtonType${index}" value="1" class="nodeTypeClick" ${disabledA ? 'disabled' : ''}/>通过</label>
                        <label class="fc-group">
                            <input type="radio" name="nodeButtonType${index}" value="2" class="nodeTypeClick" ${disabledB ? 'disabled' : ''}/>退回</label>
                        <label class="fc-group">
                            <input type="radio" name="nodeButtonType${index}" value="3" class="nodeTypeClick" ${disabledC ? 'disabled' : ''}/>拒绝</label>
                        <label class="fc-group">
                            <input type="radio" name="nodeButtonType${index}" value="4" class="nodeTypeClick" checked/>自定义</label>
                    </dd>
                </div>
                <div>
                    <dt><span class="fc-star">*</span>按钮id：</dt>
                    <dd class="fc-form-inline">
                        <input type="text" name="nodeButtonId" autocomplete="off" placeholder="请输入按钮id" onkeyup="value=value.replace(/[^a-zA-Z0-9]/g,'')" class="fc-ipt fc-ipt-auto btnidBlur">
                    </dd>
                </div>
                <div>
                    <dt><span class="fc-star">*</span>按钮名称：</dt>
                    <dd class="fc-form-inline">
                        <input type="text" name="btnName" value="自定义" autocomplete="off" placeholder="请输入按钮名称" class="fc-ipt fc-ipt-auto">
                    </dd>
                </div>
                <div class="third defaultRadio">
                    <dt><span class="fc-star">*</span>默认事件：</dt>
                    <dd style="flex: auto;">
                        <label class="fc-group">
                            <input type="radio" name="defaultEvent${index}" value="0" class="defaultEvent" checked/>否</label>
                        <label class="fc-group">
                            <input type="radio" name="defaultEvent${index}" value="1" class="defaultEvent" />是</label>
                    </dd>
                </div>
                <div class="liuzhuanBox">
                    <dt><span class="fc-star">*</span>流转方式：</dt>
                    <dd style="flex: auto;">
                        <label class="fc-group">
                            <input type="radio" name="transferWay${index}" value="1" class="selectNodeRadio" checked/>下一节点</label>
                        <label class="fc-group">
                            <input type="radio" name="transferWay${index}" value="2" class="selectNodeRadio"/>上一节点</label>
                        <label class="fc-group">
                            <input type="radio" name="transferWay${index}" value="3" class="selectNodeRadio"/>指定节点</label>
                    </dd>
                </div>
                <div class="customNodeSelectLine fc-hide">
                    <dt><span class="fc-star">*</span>指定节点：</dt>
                    <dd style="flex: auto;">
                        <select class="customNodeSelect customNodeSelect${index}">`
        // if (nodesAlls.length > 0) {
        //     html += '<option value="">请选择</option>'
        //     nodesAlls.forEach(x => {
        //         html += `<option value="${x.nodeId}">${x.nodeName}</option>`
        //     })
        // } else {
        //     html += '<option value="">暂无选项</option>'
        // }
        html += `</select>
                    </dd>
                </div>
                <div>
                    <dt>自定义事件：</dt>
                    <dd style="flex: auto;">
                        <select class="customEvent">`
        if (beanEventList.length > 0) {
            html += `<option value="">请选择</option>`
            beanEventList.forEach(item => {
                html += `<option value="${item}">${item}</option>`
            })
        } else {
            html += `<option value="">暂无选项</option>`
        }
        html += `</select>
                    </dd>
                </div>
            </dl>`
        $('.allBtnContainer').append(html)
        initClick()
        let nodeIds=$(datas).parents().find("input[name='nodeIds']").val()
        getAllNodes(nodeIds, ".customNodeSelect"+index, "transferWay" + index)
    }
    $('body').on('click', '.delBtn', function (e) {
        let ele = $(e.currentTarget).parent()
        $(ele).remove()
        // if ($('.buttonDiv').length == 1) {
        //     layer.msg('至少设置一个按钮！', {
        //         icon: 5,
        //         zIndex: 1989202290
        //     })
        //     // parent.layer.msg('至少设置一个按钮！',{
        //     //     icon:6
        //     // })
        //     return false;
        // } else {
        //     $(ele).remove()
        //     // febs.modal.confirm('删除按钮', '确定删除该按钮吗？', null,null,{zIndex:1989202290},function (data) {
        //     //     $(ele).remove()
        //     // });
        // }
    })

    function initClick() {
        // 默认事件切换
        $('.defaultEvent').click(function (e) {
            let val = $(e.currentTarget).val()
            if (val == '0') {
                $(e.target).parents('.buttonDiv').find('.liuzhuanBox').removeClass('fc-hide')
                if ($(e.target).parents('.buttonDiv').find('.liuzhuanBox').find('input[type="radio"]:checked').val() != 3) {
                    $(e.target).parents('.buttonDiv').find('.customNodeSelectLine').addClass('fc-hide')
                } else {
                    $(e.target).parents('.buttonDiv').find('.customNodeSelectLine').removeClass('fc-hide')
                }
            } else {
                $(e.target).parents('.buttonDiv').find('.liuzhuanBox').addClass('fc-hide')
                $(e.target).parents('.buttonDiv').find('.customNodeSelectLine').addClass('fc-hide')
            }
        })
        // 按钮类型切换
        $('.nodeTypeClick').click(function (e) {
            let val = $(e.currentTarget).val()
            let parent = $(e.target).parents('.buttonDiv')
            let allBox = parent.siblings('.buttonDiv')
            let oldvalue = $($(e.target).parents('.buttonDiv')).find('.radioLine').attr('data-oldvalue')

            if (val == '4') {
                // 自定义
                for (let key in allBox) {
                    if (typeof key == 'string' && !isNaN(Number(key))) {
                        $($($(allBox[key]).find('.radioLine')).find(`input[value=${oldvalue}]`)).removeAttr('disabled')
                    }
                }

                // 默认事件改成否
                $(parent).find('.defaultEvent').each((v, h) => {
                    if ($(h).val() == 0) {
                        $(h).prop('checked', true)
                    }
                })
                // 隐藏默认事件radio

                $(parent).find('.defaultRadio').addClass('fc-hide')
                $($(parent).find('.liuzhuanBox')).removeClass('fc-hide')
            } else {
                for (let key in allBox) {
                    if (typeof key == 'string' && !isNaN(Number(key))) {
                        $($($(allBox[key]).find('.radioLine')).find(`input[value=${oldvalue}]`)).removeAttr('disabled')
                        $($($(allBox[key]).find('.radioLine')).find(`input[value=${val}]`)).prop('disabled', true)
                    }
                }
                // 默认事件改成是
                $(parent).find('.defaultEvent').each((v, h) => {
                    if ($(h).val() == 1) {
                        $(h).prop('checked', true)
                    }
                })
                $($(parent).find('.liuzhuanBox')).addClass('fc-hide')
                $($(parent).find('.customNodeSelectLine')).addClass('fc-hide')
                $(parent).find('.defaultRadio').removeClass('fc-hide')
            }
            // 按钮名称赋值
            let nodeName = val == 1 ? '通过' : val == 2 ? '退回' : val == 3 ? '拒绝' : '自定义'
            $($(parent).find('input[name=workflowNodeName ]')).val(nodeName)
            $(e.currentTarget).parents('.radioLine').attr('data-oldvalue', val)

            form.render()
        })
        // 流转方式切换
        $('.selectNodeRadio').click(function (e) {
            let val = $(e.currentTarget).val()
            let parent = $(e.target).parents('.buttonDiv')
            if (val == '3') {
                // 指定节点
                $($(parent).find('.customNodeSelectLine')).removeClass('fc-hide')
                // todo:获取页面的节点渲染下拉
            } else {
                $($(parent).find('.customNodeSelectLine')).addClass('fc-hide')
            }
        })
        // 按钮id输入不能重复
        $('.btnidBlur').blur(function (e) {
            let val = $(e.currentTarget).val()
            if (val != '' && val != undefined && val != null) {
                let parent = $(e.target).parents('.buttonDiv')
                let otherBox = parent.siblings('.buttonDiv')
                for (let key in otherBox) {
                    if (typeof key == 'string' && !isNaN(Number(key))) {
                        let otherval = $(otherBox[key]).find('.btnidBlur').val()
                        if (val == otherval) {
                            $(e.currentTarget).val('')
                            layer.msg('按钮id不能重复！', {
                                icon: 5,
                                zIndex: 1989202290
                            })
                            return false
                        }
                    }
                }
            }

        })
    }

    var bussinessList = []

    function getBussinessList(workflowBusiness, properties) {
        febs.get(ctx + 'workflowInfo/getNodeByWorkflowName', {workflowBusiness: workflowBusiness}, function (res) {
            // 赋值业务模块下拉
            if (res.code == 200) {
                $('#businessNodeId').empty()
                if (res.data && res.data.length > 0) {
                    let html = '<option value="">请选择</option>'
                    res.data.forEach(item => {
                        html += `<option value="${item.nodeId}">${item.nodeName}</option>`
                    })
                    $('#businessNodeId').append(html)
                    bussinessList = res.data
                } else {
                    $('#businessNodeId').append('<option value="">暂无选项</option>')
                }
                if (!$.isEmptyObject(properties)) {
                    // 业务模块编辑回显
                    $('#businessNodeId').val(properties.businessNodeId)
                }
            }
        })
    }

    var nodesAll = []
    var nodesAlls = []

    // 获取所有节点除去抄送和条件,去掉点击的自己
    function getAllNodes(nodeId, selectClassName, radioName) {
        let objAll = JSON.parse(workflow.getJson())
        nodesAll = []
        fn(objAll)
        let optionHtml = '<option value="">请选择</option>'
        if (nodesAll.length > 0) {
            let otherNodesAll = nodesAll.filter(item => {
                if (item.nodeId != nodeId && !commonJS.isEmpty(nodeId)) {
                    return true
                } else {
                    return false
                }
            })
            nodesAlls = otherNodesAll
            if (otherNodesAll.length > 0) {
                otherNodesAll.forEach(item => {
                    optionHtml += `<option value="${item.nodeId}">${item.nodeName}</option>`
                })
            } else {
                optionHtml = '<option value="">暂无选项</option>'
            }
        }
        if (null != selectClassName && selectClassName != "") {
            if (nodesAlls.length == 0) {
                $($("input[name='" + radioName + "']")[2]).prop("disabled", true)
            }
            $(selectClassName).append(optionHtml)
        } else {
            if (nodesAlls.length == 0) {
                $('.customNodeSelect').parents().find("input[name='transferWay1'][value='3']").prop("disabled", true)
                $('.customNodeSelect').parents().find("input[name='transferWay2'][value='3']").prop("disabled", true)
                $('.customNodeSelect').parents().find("input[name='transferWay3'][value='3']").prop("disabled", true)
            }
            $('.customNodeSelect').append(optionHtml)
        }

    }

    function fn(objAll) {
        if (objAll.type == "approve") {
            let obj = {
                nodeName: objAll.name || '',
                nodeId: objAll.nodeId
            }
            nodesAll.push(obj)
        }
        if (!!objAll.childNode) {
            fn(objAll.childNode)
        }
        if (objAll.conditionNodes && objAll.conditionNodes.length > 0) {
            objAll.conditionNodes.forEach(item => {
                if (!!item.childNode) {
                    fn(item.childNode)
                }
            })
        }
    }

    //抄送自定义权限
    function getNotifier(workflowNodeCheckIds) {
        febs.get(ctx + 'workflowNode/queryWorkflowCustomBean', {classType: "3"}, function (res) {
            if (res.code === 200) {
                let html = '<option value="">请选择</option>'
                if (res.data && res.data.length > 0) {
                    res.data.forEach(item => {
                        html += `<option value="${item}">${item}</option>`
                    })
                } else {
                    html = `<option value="暂无选项">暂无选项</option>`
                }
                $('#notifierQX').empty()
                $('#notifierQX').append(html)
                $('#notifierQX').val(workflowNodeCheckIds)
            }
        });
    }

    //添加节点条件
    window.addCondition = function () {
        let index = Math.floor(Math.random() * (9999 - 1000)) + 1000
        let htl = `<dl class="conditionDiv">
                    <i class="layui-icon layui-icon-close conditionBtn"></i>
                    <div class="first">
                        <dt><span class="fc-star">*</span>条件类型：</dt>
                        <dd style="flex: auto;">
                             <label class="fc-group">
                                <input type="radio" name="conditionType${index}" value="1" data-type="4" checked onclick="workflowConditionTypes(this)"/>
                                发起人部门
                            </label>
                            <label class="fc-group">
                                <input type="radio" name="conditionType${index}" value="2" data-type="3" onclick="workflowConditionTypes(this)"/>
                                发起人角色
                            </label>
                            <label class="fc-group">
                                <input type="radio" name="conditionType${index}" value="3" data-type="1" onclick="workflowConditionTypes(this)"/>
                                上一级操作
                            </label>
                            <label class="fc-group">
                                <input type="radio" name="conditionType${index}" value="4" data-type="2" onclick="workflowConditionTypes(this)"/>
                                自定义
                            </label>
                            <br/>
                            <br/>
                            <label class="fc-group" style="margin-left: 0;">
                                <input type="radio" name="conditionType${index}" value="5" data-type="5"
                                       onclick="workflowConditionTypes(this)"/>
                                业务字段
                            </label>
                        </dd>
                    </div>
                    <div class="second screen">
                        <dt><span class="fc-star">*</span>条件筛选：</dt>
                        <dd style="display: flex;align-items: center">
                            <div style="margin-top: 0;display: flex;" class="selectName"></div>
                            <button type="button" name="addApproveUser" plain=""
                                    class="layui-btn layui-btn-primary layui-border-blue layui-btn-sm"
                                    onclick="selConditionUser(this)">
                                <i class="layui-icon layui-icon-add-1"></i>
                                选择
                            </button>
                        </dd>
                    </div>
                    <div class="third formual">
                        <dt><span class="fc-star">*</span>条件公式：</dt>
                        <dd style="flex: auto;">
                            <label class="fc-group"><input type="radio" name="conditionOperation${index}" value="1"
                                                           checked/>属于</label>
                            <label class="fc-group"><input type="radio" name="conditionOperation${index}" value="2"/>不属于</label>
                        </dd>
                    </div>
                     <input type="text" name="roleName" class="fc-ipt fc-ipt-auto fc-hide">
                    <input type="text" name="roleId" class="fc-ipt fc-ipt-auto fc-hide">
                    <input type="text" name="deptName" class="fc-ipt fc-ipt-auto fc-hide">
                    <input type="text" name="deptId" class="fc-ipt fc-ipt-auto fc-hide">
                    <div class="lastLevel" style="display: none">
                        <dt><span class="fc-star">*</span>操作按钮：</dt>
                        <dd>
                            <select class="lastNode${index}">
                               
                            </select>
                        </dd>
                    </div>
                    <div class="custom" style="display: none">
                        <dt><span class="fc-star">*</span>自定义：</dt>
                        <dd>
                            <select class="getBranch${index}">
                            </select>
                        </dd>
                    </div>
                    <div class="tableNames" style="display: none">
                        <dt><span class="fc-star">*</span>业务表：</dt>
                        <dd>
                            <select class="tableNameSelect${index} sameSelect" onchange="tableNameSelectChange(this)">

                            </select>
                        </dd>
                    </div>
                    <div class="tableNameSelects" style="display: none">
                        <dt><span class="fc-star">*</span>表字段：</dt>
                        <dd>
                            <select class="tableNameSelectChild">
                                <option value="">暂无选项</option>
                            </select>
                        </dd>
                    </div>
                    <div class="five" style="display: none">
                        <dt><span class="fc-star">*</span>条件公式：</dt>
                        <dd style="flex: auto;">
                            <label class="fc-group"><input type="radio" name="conditionOperationLast${index}" value="1" checked/>属于</label>
                            <label class="fc-group"><input type="radio" name="conditionOperationLast${index}" value="2"/>不属于</label>
                            <label class="fc-group"><input type="radio" name="conditionOperationLast${index}" value="3"/>大于</label>
                            <label class="fc-group"><input type="radio" name="conditionOperationLast${index}" value="4"/>大于等于</label>
                            <label class="fc-group"><input type="radio" name="conditionOperationLast${index}" value="5"/>小于</label>
                            <label class="fc-group"><input type="radio"  name="conditionOperationLast${index}" value="6"/>小于等于</label>
                        </dd>
                    </div>
                    <div class="six" style="display: none">
                        <dt><span class="fc-star">*</span>对比值：</dt>
                        <dd style="flex: auto;">
                            <label class="fc-group"><input type="text" name="conditionValue" placeholder="请输入对比值"/></label>
                        </dd>
                    </div>
                </dl>`
        $("#conditionDivs").append(htl)
        getLast(branchNode, "lastNode" + index)
        getBranch("getBranch" + index);
        getTableNameList("tableNameSelect" + index)
    }

    $('body').on('click', '.conditionBtn', function (e) {
        let ele = $(e.currentTarget).parent()
        if ($('.conditionDiv').length == 1) {
            layer.msg('节点条件不可为空！', {
                icon: 5,
                zIndex: 1989202290
            })
            return false;
        } else {
            $(ele).remove()
        }
    })

    var lastNodes;
    var map = new Map();

    function getLast(nodeId, selectClass) {
        let objAll = JSON.parse(workflow.getJson())
        lastNodes = []
        fnLast(objAll, nodeId)
        if (selectClass) {
            $('.' + selectClass).empty()
        } else {
            $(".lastNode").empty()
        }
        let optionHtml = '<option value="">请选择</option>'
        if (lastNodes.length > 0) {
            for (let i = 0; i < lastNodes.length; i++) {
                optionHtml += `<option value="${lastNodes[i].nodeButtonId}">${lastNodes[i].nodeButtonName}</option>`
            }
            $(".lastNode").parents().find(".first").find("input[value='3']").removeAttr('disabled')
        } else {
            optionHtml = '<option value="">暂无选项</option>'
            $(".lastNode").parents().find(".first").find("input[value='3']").prop('disabled', true)
        }
        if (selectClass) {
            $('.' + selectClass).append(optionHtml)
        } else {
            $(".lastNode").append(optionHtml)
        }
    }

    //obj当前的数据  targetNodeId对应的那个节点
    function fnLast1(obj, targetNodeId) {
        if (obj) {
            map.set(obj.nodeId, obj)
            if (obj.type == "notifier") {//抄送节点
                if (obj.childNode) {
                    fnLast1(obj.childNode, targetNodeId, obj.prevId)
                }
            } else if (obj.type == "route") {//添加分支节点
                for (let i = 0; i < obj.conditionNodes.length; i++) {
                    let conditionNode = obj.conditionNodes[i];
                    if ("condition" == conditionNode.type) {//分支节点
                        if (conditionNode.nodeId == targetNodeId) {//判断是否与传进来的nodeId相等
                            findApproveNode(conditionNode.prevId)
                        } else {
                            map.set(conditionNode.nodeId, conditionNode)
                            fnLast1(conditionNode.childNode, targetNodeId, conditionNode.prevId)
                        }
                    } else {
                        map.set(conditionNode.nodeId, conditionNode)
                        fnLast1(conditionNode.childNode, targetNodeId, conditionNode.prevId)
                    }
                }
            } else if (obj.type == "approve") {
                if (obj.childNode) {
                    fnLast1(obj.childNode, targetNodeId, obj.prevId)
                }
            }
        }
    }

    function findApproveNode(nodeId) {
        let prevNode = map.get(nodeId);
        if (prevNode) {
            if (prevNode.nodeId && "approve" == prevNode.type) {
                let obj = map.get(prevNode.nodeId);
                if(!$.isEmptyObject(obj.properties)){
                    lastNodes = obj.properties.btnSetList;
                }
            } else {
                findApproveNode(prevNode.prevId)
            }
        }
    }

    function fnLast(objAll, nodeId) {
        var oneChild = objAll;
        fnLast1(oneChild.childNode, nodeId)
    }

    //分支自定义权限
    let branchList = []

    function getBranch(selectClass) {
        febs.get(ctx + 'workflowNode/queryWorkflowCustomBean', {classType: "4"}, function (res) {
            if (res.code === 200) {
                let html = '<option value="">请选择</option>'
                if (res.data && res.data.length > 0) {
                    res.data.forEach(item => {
                        html += `<option value="${item}">${item}</option>`
                    })
                } else {
                    html = `<option value="暂无选项">暂无选项</option>`
                }
                if (selectClass) {
                    $('.' + selectClass).empty()
                    $('.' + selectClass).append(html)
                } else {
                    $('.branchSelect').empty()
                    $('.branchSelect').append(html)
                }
                branchList = res.data
            }
        });
    }

    var tableNameList = []

    //获取业务表
    function getTableNameList(selectTableClass) {
        febs.get(ctx + 'workflowNode/queryWorkflowTable', null, function (res) {
            if (res.code === 200) {
                let html = '<option value="">请选择</option>'
                if (res.data && res.data.length > 0) {
                    res.data.forEach(item => {
                        html += `<option value="${item.TABLE_NAME}">${item.COMMENTS}</option>`
                    })
                } else {
                    html = `<option value="暂无选项">暂无选项</option>`
                }
                if (selectTableClass) {
                    $('.' + selectTableClass).empty()
                    $('.' + selectTableClass).append(html)
                } else {
                    $('.tableNameSelect').empty()
                    $('.tableNameSelect').append(html)
                }
                tableNameList = res.data
            }
        });
    }

    //切换业务表
    window.tableNameSelectChange = function (data) {
        let tableName = $(data).val();
        let tableSelect = $($(data).parent().parent().parent()).find(".tableNameSelectChild")
        febs.get(ctx + 'workflowNode/queryWorkflowTableColums', {name: tableName}, function (res) {
            if (res.code === 200) {
                let html = '<option value="">请选择</option>'
                if (res.data && res.data.length > 0) {
                    res.data.forEach(item => {
                        html += `<option value="${item.COLUMN_NAME}">${item.COMMENTS}</option>`
                    })
                } else {
                    html = `<option value="暂无选项">暂无选项</option>`
                }
                tableSelect.empty()
                tableSelect.append(html)
            }
        });
    }
    //表字段数据回显
    window.initTableNameSelectInfo = function () {
        selectMap.forEach(function (val, key) {
            febs.get(ctx + 'workflowNode/queryWorkflowTableColums', {name: val.businessTable}, function (res) {
                if (res.code === 200) {
                    let tableSelect = $($(key).parent().parent().parent()).find(".tableNameSelectChild")
                    let html = '<option value="">请选择</option>'
                    if (res.data && res.data.length > 0) {
                        res.data.forEach(item => {
                            html += `<option value="${item.COLUMN_NAME}" ${item.COLUMN_NAME == val.conditionKey ? 'selected' : ''}>${item.COMMENTS}</option>`
                        })
                    } else {
                        html = `<option value="暂无选项">暂无选项</option>`
                    }
                    tableSelect.append(html)
                }
            });
        })
    }

    window.clearWorkFlow = function (d) {
        workflow = new Workflow({
            menus: [{
                type: 'approve', // 节点类型：node-条件节点
                icon: 'user-o', // 图标，参考 fontasome
                color: 'orange', // 图标颜色定制，默认蓝色
                text: '业务节点',
                node: { // 可预定义配置
                    tips: '业务节点',
                    icon: 'edit',
                    name: '业务节点',
                    text: '请配置业务节点', // 也支持function，this指向 properties
                    properties: {}
                },
                // 自定义非空验证规则
                valid: function (data) {
                    let approveNodeData = data.properties
                    // 返回 false 验证通过
                    return false
                },
                handler: function (node, event) {
                    var el = node.el;
                    var data = node.data;
                    $.ux.drawer({
                        title: '',
                        html: $.ux.template('tpl-review', node.data),
                        onok: function (e) {
                            if (e.button.className == "ajs-ok" && e.button.text == "确 定") {
                                let $form = $(".ajs-dialog form")
                                let workflowNodeName = $form.find("input[name='workflowNodeName']").val()//节点名称
                                let businessNodeId = $form.find("#businessNodeId option:selected").val()//业务模块
                                let businessNodeName = $form.find("#businessNodeId option:selected").text()//业务模块名称
                                let workflowNodeCheckType = $form.find("input[name='workflowNodeCheckType']:checked").val()//权限设置
                                let nodeBeforeReviewFlg = $form.find("input[name='nodeBeforeReviewFlg']:checked").val()//是否允许加签
                                let nodeModifyFlg = $form.find("input[name='nodeModifyFlg']:checked").val()//是否允许修改
                                let remark = $form.find("textarea[name='remark']").val()
                                let workflowInfoObj = {
                                    workflowNodeName: workflowNodeName,
                                    businessNodeId: businessNodeId,
                                    businessNodeName: businessNodeName,
                                    workflowNodeCheckType: workflowNodeCheckType,
                                    nodeBeforeReviewFlg: nodeBeforeReviewFlg,
                                    nodeModifyFlg: nodeModifyFlg,
                                    remark: remark
                                }
                                workflow.setProperties(node.data, workflowInfoObj)
                                node.data.name = workflowNodeName
                                node.data.text = remark
                                workflow.setName(node, workflowNodeName)
                                workflow.setText(el, remark)
                                workflow.valid(node)
                            }
                        }
                    }).set('width', 640)
                }
            },
                {
                    type: 'notifier',
                    icon: 'send',
                    text: '抄送节点',
                    color: 'green',
                    node: {
                        tips: '抄送',
                        icon: 'send',
                        name: '',
                        color: 'green', // 定义不同色块(blue/green/orange)，也支持色值(#b99a01)
                        text: '请配置抄送节点', // 也支持function，this指向 properties
                    },
                    // 自定义非空验证规则
                    valid: function (data) {
                        // 返回 false 验证通过
                        return false
                    },
                    handler: function (node, event) {
                        var el = node.el;
                        var data = node.data;
                        //初始化自定义权限
                        getNotifier()

                        $.ux.drawer({
                            title: '',
                            html: $.ux.template('tpl-copyFor', node.data),
                            onok: function (e) {
                                let $form = $(".ajs-dialog form")
                                if (e.button.className == "ajs-ok" && e.button.text == "确 定") {
                                    let $form = $(".ajs-dialog form")
                                    let workflowNodeName = $form.find("input[name='workflowNodeName']").val()//节点名称
                                    let workflowNodeCheckType = $form.find("input[name='workflowNodeCheckType']:checked").val()//抄送类型
                                    let remark = $form.find("textarea[name='remark']").val()//备注
                                    let workflowInfoObj = {
                                        workflowNodeName: workflowNodeName,
                                        workflowNodeCheckType: workflowNodeCheckType,
                                        remark: remark
                                    }
                                    workflow.setProperties(node.data, workflowInfoObj)
                                    node.data.name = workflowNodeName
                                    node.data.text = remark
                                    workflow.setName(node, workflowNodeName)
                                    workflow.setText(el, remark)
                                    workflow.valid(node)
                                }
                            }
                        }).set('width', 640)
                    }
                },
                {
                    type: 'condition',
                    icon: 'sitemap',
                    text: '条件分支',
                    handler: function (node, event) {
                        var el = node.el;
                        var data = node.data;
                        $.ux.drawer({
                            title: '',
                            html: $.ux.template('tpl-condition', node.data),
                            onshow: function () {
                                let $form = $(".ajs-dialog form")
                                $form.find(".condition-form-field").hide()
                            },
                            onok: function (e) {
                                let $form = $(".ajs-dialog form")
                                if (e.button.className == "ajs-ok" && e.button.text == "确 定") {
                                    let workflowNodeName = $form.find("input[name='workflowNodeName']").val()
                                    let remark = $form.find("textarea[name='remark']").val()//备注

                                    let workflowInfoObj = {
                                        workflowNodeName: workflowNodeName,
                                        workflowNodeTransOrder: $form.find("input[name='workflowNodeTransOrder']").val(),
                                        workflowNodeTransType: $form.find("input[name=workflowNodeTransType]:checked").val(),
                                        remark: remark
                                    }
                                    workflow.setProperties(node.data, workflowInfoObj)
                                    node.data.name = workflowNodeName
                                    node.data.text = remark
                                    workflow.setName(node, workflowNodeName)
                                    workflow.setText(el, remark)
                                    workflow.valid(node)
                                }
                            }
                        }).set('width', 640)
                    }
                }],
        })
    }
});